package cn.edu.zafu.bigdata.x.zhaobolei.Fifth;

class InvalidAgeException extends Exception {
    public InvalidAgeException(String message) {
        super(message);
    }
}

public class CheckAge {
    public static void checkAge(int age) throws InvalidAgeException {
        if (age < 18) {
            throw new InvalidAgeException("未成年人禁止入内！");
        }
        System.out.println("已成年！");
    }

    public static void main(String[] args) {
        try {
            checkAge(25);
            checkAge(15);
        } catch (InvalidAgeException e) {
            System.out.println("Error：" + e.getMessage());
        }
    }
}